package com.gzx.risk.core.apis.result.yuyao;

import java.util.Map;

import org.apache.commons.lang3.StringUtils;

import com.gzx.risk.core.apis.result.RiskResult;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

/**
 * {"code":0,"msg":"操作成功","data":{"flag_applyloanstr":1}}
 */
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class YuyaoBrdt_score extends RiskResult {
	private int code;
	private String msg;
	private Map<String, Object> data;

	public String getValue(String key) {
		if (data != null && data.containsKey(key)) {
			return data.get(key).toString();
		} else {
			return "";
		}
	}

	public Double getNum(String key) {
		String value = getValue(key).trim();
		if (value.length() > 0) {
			return Double.valueOf(value);
		} else {
			return -1.0;
		}
	}

	public Double getRate(String key1, String key2) {
		String value2 = getValue(key2).trim();
		if (StringUtils.isEmpty(value2)) {
			return -1000.0;
		}

		String value1 = getValue(key1).trim();
		if (StringUtils.isEmpty(value1)) {
			return -999.0;
		}
		return Double.valueOf(value1) / Double.valueOf(value2);
	}
}
